package iosr11.data;

import java.util.ArrayList;
import java.util.List;

public class Student extends Entity{

	/* brak listy obecności, grupy do zmiany: zamiast String -> Group */
	private ProjectGroup projectGrp;
	private List<Mark> grades;
	private List<Attendence> attendences;
	private User user;
	private int indexNumber;
	public List<Group> getGroups() {
		return user.getGroups();
	}
	public void setGroups(List<Group> groups) {
		this.user.setGroups(groups);
	}
	public ProjectGroup getProjectGrp() {
		return projectGrp;
	}
	public void setProjectGrp(ProjectGroup projectGrp) {
		this.projectGrp = projectGrp;
	}
	public List<Mark> getGrades() {
		return grades;
	}
	public void addGroup(Group group){
		this.user.addGroup(group);
	}
	public void setGrades(List<Mark> grades) {
		this.grades = grades;
	}
	public String getName() {
		return user.getName();
	}
	public void setName(String name) {
		this.user.setName(name);
	}
	public String getEmail() {
		return user.getEmail();
	}
	public void setEmail(String email) {
		this.user.setEmail(email);
	}
	public int getIndexNumber() {
		return indexNumber;
	}
	public void setIndexNumber(int indexNumber) {
		this.indexNumber = indexNumber;
	}
	
	public Student(User user){
		this.user=user;
	}
	
	public Student(){
		user = new User();
	}
	/*
	public Student(String studentId, User user, int indexNumber, List<String> groups){
		super(studentId);
		this.user = user;
		this.groups=groups;
		this.indexNumber = indexNumber;
	}*/
	
	public User getUser() {
		return user;
	}
	public void setUser(User user) {
		this.user = user;
	}
	
	public boolean addMark(Mark mark){
		if (mark==null) return false;
		mark.setStudent(this);
		if (grades == null)
			grades = new ArrayList<Mark>();
		this.grades.add(mark);
		return true;
	}
	
	public List<Attendence> getAttendences() {
		return attendences;
	}
	public void setAttendences(List<Attendence> attendences) {
		this.attendences = attendences;
	}
	public String toString(){
		StringBuffer buf = new StringBuffer();
		buf.append("Dane studenta:\n");
		buf.append(this.getId());
		buf.append("\n");
		if (this.getProjectGrp()!=null){
			if (this.getProjectGrp().getGroupName()!=null){
				buf.append(this.getProjectGrp().getGroupName());
				buf.append("\n");
			}
		}
		buf.append(user.getName());
		buf.append("\n");
		buf.append(user.getEmail());
		buf.append("\n");
		buf.append("Oceny: ");
		if (grades!=null)
		for (Mark mark : this.grades){
			buf.append(mark.getGrade());
			buf.append("  ");
		}
		else buf.append("brak ocen");
		buf.append("\n");
		buf.append("Obecnosci: ");
		if (attendences!=null)
		for (Attendence attendence : attendences){
			buf.append(attendence.getPressence());
			buf.append("   ");
		}
		else buf.append("brak obecnosci");
		buf.append("\n");
		buf.append(indexNumber);
		buf.append("\n");
		
		return buf.toString();
	}
}
